package com.bbh.plugin.single.privilege.core.conf;

import com.bbh.common.constants.Constants;
import com.bbh.common.utils.web.spring.SpringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

/**
 * Created by roman_000 on 2016/6/27.
 */
@Component
@ConfigurationProperties(prefix = Constants.SETTING_PREFIX + ".settings")
public class SettingProperties {

    private String captchaTypes;

    public String getCaptchaTypes() {
        return captchaTypes;
    }

    public void setCaptchaTypes(String captchaTypes) {
        this.captchaTypes = captchaTypes;
    }

    public boolean hasCaptchaType(String captchaType) {
        if (StringUtils.isNotBlank(captchaTypes)) {
            return (StringUtils.indexOf(StringUtils.replacePattern("," + captchaTypes + ",", "\\s+", ""), captchaType) > 0);
        }
        return false;
    }

}

